/*
 * Lucas McDaniel
 * GSoC '11
 * HoneyViz
 * 
 * This class ties a type of event or location with a specific color and offset.  
 * Since varying degrees of information may be known during the creation of 
 * the object, several constructors are available.  The offset is a randomly 
 * generated (or selected) value that shifts the location the event was seen by 
 * at most 3 pixels in any direction.  This allows smaller events to be put off 
 * center so that they are not completely covered up by larger events in the 
 * case that the visualization is not set to group mode.
 */

import java.awt.Color;
import java.util.Random;

public class EventColor {
    public String name;
    public int key;
    public Color paint;
    public int locXOffset;
    public int locYOffset;
    
    public EventColor(String name)
    {
        this.name = name;
        makeRandom(name.hashCode());
    }
    
    public EventColor(String name, int key, Color paint)
    {
        this.name = name;
        this.key = key;
        this.paint = paint;
        makeRandom(name.hashCode());
    }
    
    public EventColor(String name, int key, Color paint, int x, int y)
    {
        this.name = name;
        this.key = key;
        this.paint = paint;
        locXOffset = x;
        locYOffset = y;
    }
    
    public void set(int key, Color paint)
    {
        this.key = key;
        this.paint = paint;
    }
    
    public EventColor makeNew()
    {
        return new EventColor(name, key, paint);
    }
    
    public void makeRandom(long seed)
    {
        Random gen = new Random(seed);
        locXOffset = gen.nextInt(7);
        locYOffset = gen.nextInt(7);
    }
    
    public String toString()
    {
        return name + "\t" + paint;
    }
}
